<%--
  - $RCSfile$
  - $Revision: $
  - $Date: $
  -
  - Copyright (C) 2003-2008 Jive Software. All rights reserved.
  -
  - This software is published under the terms of the GNU Public License (GPL),
  - a copy of which is included in this distribution, or a commercial license
  - agreement with Jive.
--%>

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page errorPage = "fatal.jsp"
         import = "com.infoview.db.*, java.sql.*,
         			org.jivesoftware.webchat.*,
                   java.util.Map,
                   org.jivesoftware.webchat.util.FormText" %><%@ page import="com.jivesoftware.smack.workgroup.settings.SoundSettings"%><%@ page import="org.jivesoftware.smack.XMPPException"%><%@ page import="org.jivesoftware.webchat.util.WebUtils"%>
<%@ page import="org.jivesoftware.webchat.util.StringUtils" %>
<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/interface/room.js'></script>
<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/engine.js'></script>

<%
	String path = request.getContextPath();
	String serverPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/";
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	
   final String chatID = request.getParameter("chatID");
   final String workgroup = request.getParameter("workgroup");
   final String city = request.getParameter("city");

   ChatManager chatManager = ChatManager.getInstance();
   ChatSession chatSession = chatManager.getChatSession(chatID);
   
   final String sessionID = chatSession.getSessionID();

   final Map map = chatSession.getMetaData();
   String question = "";
   if (map.containsKey( ("question") )) {
     question = "问题： " + (String) map.get( "question" );
   }

   String userNickname = chatSession.getNickname();
   userNickname = WebUtils.replace(userNickname, "'", "&apos;");
   userNickname = WebUtils.replace(userNickname, "\"", "&quot;");
   

   String ad_pic = "http://127.0.0.1:8080/webchat/ad/gz.png";
   try {
		Connection conn = DbUtil.getConnection();
		
		if (conn != null) {
			String sql = "select photo from offlack where city = ?";
		      
			PreparedStatement pstmt = conn.prepareStatement(sql);
	
			pstmt.setString(1, city);
	
			ResultSet rs = pstmt.executeQuery();  //获得查询结果
			Object rt = null;
			if (rs.next()) {
			 rt = rs.getObject(1);
			}
			
			ad_pic = (String)rt;
	
			pstmt.close();
			conn.close();
			
		}

	} catch (SQLException e) {
		e.printStackTrace();
	}

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns=" http://www.w3.org/1999/xhtml">
   <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>联通在线客服</title>

    <link rel="stylesheet" type="text/css" href="style.jsp"/>
    
	<script language="JavaScript" type="text/javascript" src="js/snapshot.js"></script>
	
    <script language="JavaScript" type="text/javascript">
     var nickname = '<%= StringUtils.escapeHTMLTags(userNickname) %>';
     var isRedirecting = false;

     var checker = 0;

     var lastChecked = 0;

     DWREngine.setErrorHandler(handleError);

     function handleError(error) {
         // check for connectivity.
         if (isRedirecting) {
             return;
         }
     }

     function connectionChecker(){
         var t = new Date().getTime();
         if(t > (lastChecked + 60000) && lastChecked != 0){
            chatHasEnded(); // conversatinicknamon = 服务器?
            alert("与服务器的连接已经丢失。请关闭窗口重试。");
            window.close();
         }

         setTimeout("connectionChecker()", 5000);
     }

     connectionChecker();

     function successful(b) {
         addText('', "重新连接成功。");

         checkForNewMessages();
         checkIfAgentTyping();
         DWREngine.setErrorHandler(handleError);
         checker = 0;
     }
    </script>

    <script language="JavaScript" type="text/javascript" src="common.js"></script>

    <script language="JavaScript" type="text/javascript">
      var counter = 0;
      var cobrowseWin;

      function submitMessage() {
        var chatbox = document.f.chatbox;
        if (chatbox.value.trim() != "") {
            var val = chatbox.value;
			
            //var val_txt = reverseEmoticons(val);
			
            // submit the form to the servlet
            room.sendMessage(null, '<%= StringUtils.escapeHTMLTags(chatID) %>', val);
            // apply filters
            val = applyFilters(val);

            // put text in yak frame
            addChatText(window.frames['yak'],'<%= StringUtils.escapeHTMLTags(userNickname)%>', val);

            scrollYakToEnd(window.frames['yak']);

            // blink the window -- IE only
            if (document.all) {
                focus();
            }

            var sounds = document.getElementById("soundsEnabled");
            if (sounds != null && sounds.checked) {
                // play outgoing sound, if enabled
                document.getElementById("sounds").innerHTML=
                    "<embed src='<%= request.getContextPath()%>/sounds?workgroup=<%=StringUtils.URLEncode(workgroup, "utf-8")%>&action=outgoing' style=display:none; hidden=true autostart=true loop=false>";
            }
        }
        // reset the chatbox textarea
        chatbox.focus();
        chatbox.value = "";
    }

    function showCobrowser(url){
      var width = 800;
      var height = 700;
      var defaultOptions = "location=yes,status=no,toolbar=no,personalbar=no,menubar=no,directories=no,";
      var winleft = (screen.width - width) / 2;
      var winUp = (screen.height - height) / 2;

      defaultOptions += "scrollbars=yes,resizable=yes,top=" + winUp + ",left=" + winleft + ",";
      defaultOptions += "width=" + width + ",height=" + height;
      cobrowseWin = window.open(url, 'cobrowser', defaultOptions);

      room.sendMessage(null, '<%= StringUtils.escapeHTMLTags(chatID) %>', 'I have accepted the Cobrowse invitation for '+url);
    }

    function isTypingNotification() {
	   room.customerIsTyping(null, '<%= chatID%>');
    }

    function sentUnderMessages(msg) {
		var chatbox = document.f.chatbox;
		if (chatbox.value.trim() != "") {
		    var val = "%under&";
		    val += chatbox.value
			
		    // submit the form to the servlet
		    room.sendMessage(null, '<%= StringUtils.escapeHTMLTags(chatID) %>', val);
	    }
	}

    function chatHasEnded(){
      document.f.chatbox.disabled = true;
    }

    function handleKeyEvent(evt) {
        var el = document.f.chatbox;
        evt = (evt) ? evt : ((window.event) ? window.event : "");
        var enterPressed = ((document.all) ? evt.keyCode==13 : evt.which==13);
        if (enterPressed) {
            submitMessage();
        }
        else {
          sentUnderMessages();
          if( counter == 5 ) {
            isTypingNotification();
            counter = 0;
          }
          else {
            counter++;
          }
        }
    }
    if (!document.all && document.getElementById) {
        document.addEventListener("keyup", handleKeyEvent, true);
    }
    else if (document.all) {
        document.attachEvent("onkeyup", handleKeyEvent);
    }
/*
    function reverseEmoticons(body) {
        body = body.replace(/<img src\='images\/emoticons\/angry\.gif' border\='0'>/gi, ":o");    // :o
        body = body.replace(/<img src\='images\/emoticons\/blush\.gif' border\='0'>/gi, ":-[");  // :-[
        body = body.replace(/<img src\='images\/emoticons\/confused\.gif' border\='0'>/gi, "?:|");   // ?:|
        body = body.replace(/<img src\='images\/emoticons\/cool\.gif' border\='0'>/gi, "B-)");     // B-)
        body = body.replace(/<img src\='images\/emoticons\/blush\.gif' border\='0'>/gi, ":'(");  // :'(
        body = body.replace(/<img src\='images\/emoticons\/devil\.gif' border\='0'>/gi, "]:)"); // ]:)
		
        body = body.replace(/<img src\='images\/emoticons\/grin\.gif' border\='0'>/gi, ":-D");    // :-D
        body = body.replace(/<img src\='images\/emoticons\/happy\.gif' border\='0'>/gi, ":-)");    // :-)
        body = body.replace(/<img src\='images\/emoticons\/laugh\.gif' border\='0'>/gi, ":^0");    // :^0
        body = body.replace(/<img src\='images\/emoticons\/love\.gif' border\='0'>/gi, ":x");       // :x
        body = body.replace(/<img src\='images\/emoticons\/mischief\.gif' border\='0'>/gi, ";\\");  // ;\
		body = body.replace(/<img src\='images\/emoticons\/sad\.gif' border\='0'>/gi, ":-\(");      // :-(
		
        body = body.replace(/<img src\='images\/emoticons\/happy\.gif' border\='0'>/gi, ":-)");    // :-)
        body = body.replace(/<img src\='images\/emoticons\/plain\.gif' border\='0'>/gi, ":|");     // :|
        body = body.replace(/<img src\='images\/emoticons\/shocked\.gif' border\='0'>/gi, ":0");    // :0
        body = body.replace(/<img src\='images\/emoticons\/silly\.gif' border\='0'>/gi, ":-p");    // :-p
        body = body.replace(/<img src\='images\/emoticons\/wink\.gif' border\='0'>/gi, ";-)");     // ;-)
        body = body.replace(/<img src\='images\/emoticons\/wink\.gif' border\='0'>/gi, "(!)");     // (!)
		
        body = body.replace(/<img src\='images\/emoticons\/wink\.gif' border\='0'>/gi, "(i)");     // (i)
        body = body.replace(/<img src\='images\/emoticons\/wink\.gif' border\='0'>/gi, "(!)");     // (!)
        body = body.replace(/<img src\='images\/emoticons\/wink\.gif' border\='0'>/gi, "(!)");     // (!)
        body = body.replace(/<img src\='images\/emoticons\/wink\.gif' border\='0'>/gi, "(!)");     // (!)
        return body;
	}
*/
    // Function to handle text filter application
    function applyFilters(body) {
        // Replace ampersands
        body = body.replace(/&/gi, "&amp;");
        // Replace HTML
        body = body.replace(/</gi, "&lt;");
        body = body.replace(/>/gi, "&gt;");
        // Replace newlines
        body = body.replace(/\n/gi, "<br>");
        // text style
        body = body.replace(/\[b\]/gi, "<b>");
        body = body.replace(/\[\/b\]/gi, "</b>");
        body = body.replace(/\[i\]/gi, "<i>");
        body = body.replace(/\[\/i\]/gi, "</i>");
        body = body.replace(/\[u\]/gi, "<u>");
        body = body.replace(/\[\/u\]/gi, "</u>");
        // Emoticons
        /* full list -> :) :-) :( :-( :D :x ;\ B-) ]:) :p X-( :^O ;) ;-) :8} :_| ?:| :O :| 
		:o :-[ ?:| B-) :'( ]:) :-D :-) :^0 :x ;\ :-( :-) :| :0 :-p ;-) (!) (i) (-) (+) (heart) 
		:o :-[ ?:| B-) :'( ]:) 
		:-D :-) :^0 :x ;\ :-( 
		:-) :| :0 :-p ;-) (!)
		(i) (-) (+) (heart) 
		*/
		
				
				alert("body:"+body);
        body = body.replace(/&gt;:o/gi, "<img src='images/emoticons/angry.gif' border='0'>");    // :o
        body = body.replace(/>:o/gi, "<img src='images/emoticons/angry.gif' border='0'>");    // :o
        body = body.replace(/:-\[/gi, "<img src='images/emoticons/blush.gif' border='0'>");  // :-[
        body = body.replace(/\?:\|/gi, "<img src='images/emoticons/confused.gif' border='0'>");// ?:|
        body = body.replace(/B-\)/gi, "<img src='images/emoticons/cool.gif' border='0'>");     // B-)
        body = body.replace(/:'\(/gi, "<img src='images/emoticons/cry.gif' border='0'>");  // :'(
        body = body.replace(/\]:\)/gi, "<img src='images/emoticons/devil.gif' border='0'>"); // ]:)
		
        body = body.replace(/:-D/gi, "<img src='images/emoticons/grin.gif' border='0'>");    // :-D
        body = body.replace(/:-\)/gi, "<img src='images/emoticons/happy.gif' border='0'>");    // :-)
        body = body.replace(/:\^0/gi, "<img src='images/emoticons/laugh.gif' border='0'>");    // :^0
        body = body.replace(/:x/gi, "<img src='images/emoticons/love.gif' border='0'>");       // :x
        body = body.replace(/;\\/gi, "<img src='images/emoticons/mischief.gif' border='0'>");  // ;\
        body = body.replace(/:-\(/gi, "<img src='images/emoticons/sad.gif' border='0'>");      // :-(
		
        body = body.replace(/:-\)/gi, "<img src='images/emoticons/happy.gif' border='0'>");    // :-)
        body = body.replace(/:\|/gi, "<img src='images/emoticons/plain.gif' border='0'>");     // :|
        body = body.replace(/:0/gi, "<img src='images/emoticons/shocked.gif' border='0'>");    // :0
        body = body.replace(/:-p/gi, "<img src='images/emoticons/silly.gif' border='0'>");    // :-p
        body = body.replace(/;-\)/gi, "<img src='images/emoticons/wink.gif' border='0'>");     // ;-)
        body = body.replace(/\(!\)/gi, "<img src='images/emoticons/wink.gif' border='0'>");     // (!)
		
        body = body.replace(/\(i\)/gi, "<img src='images/emoticons/wink.gif' border='0'>");     // (i)
        body = body.replace(/\(!\)/gi, "<img src='images/emoticons/wink.gif' border='0'>");     // (!)
        body = body.replace(/\(!\)/gi, "<img src='images/emoticons/wink.gif' border='0'>");     // (!)
        //body = body.replace(/\(!\)/gi, "<img src='images/emoticons/wink.gif' border='0'>");     // (!)
		
        //body = body.replace(/:\)/gi, "<img src='images/emoticons/happy.gif' border='0'>");   // :)
        //body = body.replace(/:\(/gi, "<img src='images/emoticons/sad.gif' border='0'>");       // :(
        //body = body.replace(/:D/gi, "<img src='images/emoticons/grin.gif' border='0'>");       // :D
        //body = body.replace(/:p/gi, "<img src='images/emoticons/silly.gif' border='0'>");      // :p
        //body = body.replace(/X-\(/gi, "<img src='images/emoticons/angry.gif' border='0'>");    // X-(
        //body = body.replace(/:\^O/gi, "<img src='images/emoticons/laugh.gif' border='0'>");    // :^O
        //body = body.replace(/;\)/gi, "<img src='images/emoticons/wink.gif' border='0'>");      // ;)
        //body = body.replace(/:8\}/gi, "<img src='images/emoticons/blush.gif' border='0'>");    // :8}
        //body = body.replace(/:_\|/gi, "<img src='images/emoticons/cry.gif' border='0'>");      // :_|
        //body = body.replace(/:O/gi, "<img src='images/emoticons/shocked.gif' border='0'>");    // :O
		
		
        body = body.replace(/:file:/gi, "<img src='images/file.png' border='0'>");    // :file:
        // done!
        return body;
    }
    </script>

    <script language="JavaScript" type="text/javascript">
     function showTranscriptWindow(message) {
        isRedirecting = true;
        location.href = 'transcriptmain.jsp?workgroup=<%= StringUtils.URLEncode(workgroup, "utf-8") %>&chatID=<%= StringUtils.URLEncode(chatID, "utf-8")%>';
     }
	  
     function doit() {
    <%

      String initialAgent = chatSession.getInitialAgent();
      if(initialAgent == null){
         %>
           alert("现客服正忙，请稍候重试。")
           window.location.href = "userinfo.jsp?workgroup=<%= StringUtils.URLEncode(workgroup, "utf-8") %>&chatID=<%= StringUtils.URLEncode(chatID, "utf-8") %>";
         <%
      }
    %>
       addChatText(window.frames['yak'], '', '<%= FormText.getChatRoomWelcomeMessage(initialAgent, workgroup) %>');
       checkForNewMessages();
       checkIfAgentTyping();
     }

     function addText(from, body) {
       addChatText(window.frames['yak'], from, body);
     }
    </script>
	
	<style>
	.fright{float:right;}
	.mtop5{margin-top:5px;}
	img{ border:0;}∂
	.m_title{background:url(images/bg_top.jpg); height:40px; line-height:40px;}
	.m_title span{ margin-left:20px; color:#fff; font-size:16px;}
	.info_list{ overflow-y:scroll; width:99%;  background-color:#fff;  padding:5px 0px 5px 10px; position:absolute;  border:solid 1px #CCCCCC; bottom:140px; top:0px; right:0px; border-bottom:none;scrollbar-face-color:#d0d0d0;scrollbar-highlight-color:#fff;scrollbar-shadow-color:#d0d0d0;scrollbar-3dlight-color:#d0d0d0;scrollbar-arrow-color:#000;scrollbar-track-color:#c0c0c0;scrollbar-darkshadow-color:#ccc;}
	.info_tool{width:99%;padding:0px 5px 0px 5px; position:absolute;  line-height:25px; right:0px;  position:absolute;  background:url(../images/bg_tool.jpg);  height:25px;border-left:solid 1px #CCCCCC;border-right:solid 1px #CCCCCC;}
	.f_file{ width:17px; height:19px; display:block; background:url(images/pic_ico.jpg) -2px -1px; float:left; margin-top:5px; margin-left:30px;_margin-left:15px;}
	.f_img{ width:17px; height:19px; display:block; background:url(images/pic_ico.jpg) -27px -2px; float:left;margin-top:5px; margin-left:10px;}
	.f_face{ width:17px; height:19px; display:block; background:url(images/pic_ico.jpg) -52px -1px; float:left;margin-top:5px; margin-left:10px; }
	.message{width:100%;background-color:#fff; height:114px;}
	.table_message{ width:600px; margin-top:20px; padding-left:50px;}
	.table_message .on{ width:80px; text-align:right; height:35px; line-height:35px;}
	.table_message .normal{ padding-left:5px;}
	.add_btm{background:url(images/add_buttom.jpg); width:90px; height:33px; line-height:33px; display:block; color:#ffffff; font-size:14px; text-align:center;}
	.close_btm{width:90px; height:33px; line-height:33px; padding-left:15px; color:#ffffff; font-size:12px; text-align:center;}
	.face_list{width:200px; height:70px;  position:absolute; z-index:9000; bottom:82px; left:-30px; background-color:#fff; display:none;}
	.face_list .face_ico {  width:200px; background:#ccc; }
	.face_list .face_ico tr{background:#ccc;}
	.face_list .face_ico td{  height:22px; width:22px; padding:2px; background:#fff;text-align:center;}
	.message_input{ width:100%; height:65px; border:0; overflow-x:hidden;overflow-y: auto;padding-top:5px; color:#000; font-size:12px; text-align:left; cursor:text;}
	.l_system{ margin-left:15px; margin-top:10px;}
	.l_custom,.l_ren{ margin-left:15px; margin-top:5px;}
	.l_system span,.l_custom span,.l_ren span{ height:20px; line-height:20px;}
	.l_system .n1,.l_custom .n1 span,.l_ren .n1 span{ color:#ccc;}
	.l_custom .n1,.l_custom .n2{color:#04428f;}
	.l_ren .n1{color:#308712;}
	.buttom_login{ background:url(images/nav_left.png) right -62px no-repeat; width:73px; height:30px; display:block; color:#fff; text-align:center; line-height:30px; margin-right:12px;}
	</style>
	  <script src="js/jquery.js" type="text/javascript"></script>  
     <script type="text/javascript">
           $(function () {     
               $(".f_face").mousedown(function () {
                   $(".face_list").show("normal");
                   // reload();
               });
              $(".f_face").mouseout(function () {
                   time = setTimeout(function () {
                       closeDiv();
                   }, 200);
               });
               $(".face_list").hover(function () {
                   clearTimeout(time);
               }, function () {
                   time = setTimeout(function () {
                       closeDiv();
                   }, 200);
               });
               $(".face_ico tr td").click(function () {
                   // var _src = $(".face_ico a").eq($(".face_ico tr td").index(this)).find("img").attr("src");
                   // var img = "<img src='" + _src + "' />";
                   var _alt = $(".face_ico a").eq($(".face_ico tr td").index(this)).find("img").attr("alt");
                   $(".inputbox").append(_alt);
                   //var chatbox = document.f.chatbox;
                   //chatbox.append(_alt);
				   
                   // $("#inbox").append(_alt);

               });
               $(".f_file").click(function () {
                   $("#file").click();
               });
           });
    /*自动适应高度*/  
    function closeDiv() {
        $(".face_list").hide("normal"); 
    }
   
    function uploadFileDone(path, fileName)
	{
	$(".inputbox").append(path);
//		$(".inputbox").append(":file:<a href='"+path+"' target='_blank'>" + fileName + "</a>");
//		addText('', "<a href='"+path+"' target='_blank'>" + fileName + "</a>");
//		addText('', "<a href='"+path+"' target='_blank'>点击下载</a>");
	}
   
   
</script>

    <link type="text/css" rel="stylesheet" href="css/css.css" />
    <script src="js/jquery.js" type="text/javascript"></script>  
    <script type="text/javascript">

		function submitValuation() {
			alert("感谢您的咨询和对我们工作的评价，再见！");
			document.valuation.submit();
			//showTranscriptWindow(null);
		}
		function cancelValuation() {
			showTranscriptWindow(null);
		}
		function confirmExit() {
			var ok = confirm('你确定要结束咨询吗？');
			if(ok){
				//alert(1);
				popdiv(); //".dialog-login","400","auto",0.2 undefined
				$(".appraise").show("normal");
				$("#popbg").fadeIn();
				//showTranscriptWindow(null);
			}
		}

		function checkUnload(){
			/* alert("onUnload");
			popdiv(); //".dialog-login","400","auto",0.2 undefined
			$(".appraise").show("normal");
			$("#popbg").fadeIn();
			*/
			if(!isRedirecting){
				window.location.href = 'exit-queue.jsp?workgroup=<%=StringUtils.URLEncode(workgroup, "utf-8")%>&chatID=<%=StringUtils.URLEncode(chatID, "utf-8")%>';
			}
		}
		/*
		window.onbeforeunload = function() //author:   meizz   
		{   
			alert("是关闭而非刷新");  
			popdiv(); //".dialog-login","400","auto",0.2 undefined
			$(".appraise").show("normal");
			$("#popbg").fadeIn();
			alert("22新"); 
		
		}*/
		
		function getAd(city) {
			
		}
		
        //弹出对话框关闭操作
        $(function () {
            $('.closeme').click(function () {
                $("#popbg").fadeOut();
                $('.appraise').hide("normal");
            });
            $('#clickme').click(function () {
                //alert(1);
                popdiv(); //".dialog-login","400","auto",0.2 undefined
                $(".appraise").show("normal");
                $("#popbg").fadeIn();
            });
        });
        popdiv = function popdiv() {
        
            var _width = ($(document).width() / 2) - ($(".appraise").width() / 2); //窗口宽度 (浏览器宽度/2)-(浮动层宽度/2)
            var _height = ($(document).height() / 2) - ($(".appraise").height() / 2); //窗口高度 (浏览器高度/2)-(浮动层高度/2)
            //alert($(".appraise").width());
            //alert($(document).height());
            if ($.browser.version == "6.0")//$.browser.msie ie系列浏览器
            {
                document.getElementById('dialog-login').style.left = _width;
                document.getElementById('dialog-login').style.top = _height;
            }
            else {
                $(".appraise").css({ left: _width, top: _height });
            }

            $("#popbg").css({width:$(document).width(), height: $(document).height(), filter: "alpha(opacity=0.2)", opacity: 0.2 })



        }
        window.onresize = popdiv;
</script>


   </head>

   <body style="margin-top:0px;margin-right:20px;margin-left:20px;margin-bottom:10px;" id="defaultwindow" onLoad="doit();" onUnload="checkUnload();">

<div class="appraise"><!-- valuationServlet -->
<form id="valuation" name="valuation" method="post" action="valuationServlet?sessionID=<%= StringUtils.escapeHTMLTags(sessionID) %>&workgroup=<%= StringUtils.escapeHTMLTags(workgroup) %>&chatID=<%= StringUtils.escapeHTMLTags(chatID) %>">
	<div class="app_title">
	<strong class=" fleft">服务评价</strong>
	<a href="javascript:cancelValuation();"  title="关闭" class="app_close closeme fright"></a>
	</div>
	<dl class="app_info">
	<dt><span>您对本次服务的评价是？</span></dt>
	<dd>
	<span class=" mleft10">
		<input id="Radio1" name="grade" type="radio" value = "4" checked ="checked" style="position:relative;*+position:relative; top:2px; *+top:1px;" />非常满意</span>
	</dd>
	<dd>
	<span class=" mleft10">
		<input id="Radio2"  name="grade" type="radio" value = "3" style="position:relative;*+position:relative; top:2px; *+top:1px;" />满意</span>
	</dd>
	<dd>
	<span class=" mleft10">
		<input id="Radio3"  name="grade" type="radio" value = "2" style="position:relative;*+position:relative; top:2px; *+top:1px;" />一般</span>
	</dd>
	<dd>
	<span class=" mleft10">
		<input id="Radio4"  name="grade" type="radio" value = "1" style="position:relative;*+position:relative; top:2px; *+top:1px;" />不满意</span>
	</dd>
	<dd class="pdtop10">
	<strong>建议：</strong><br />
		<textarea id="suggest" name="suggest" class="mtop5" cols="25" rows="5"></textarea>
	</dd>
	<dd class=" mtop5">
	  <a href="javascript:cancelValuation();" class="seva fright closeme" style=" margin:0px 48px 0px 5px;_margin:0px 24px 0px 5px;" title="取消">取 消</a>
	  <a href="javascript:submitValuation();" class="normal fright" title="提交">提 交</a>
	</dd>
	</dl>
</form>
</div>
 <div id="popbg" ></div>
 
<span id=sounds></span>
  <table height="100%" width="100%" cellpadding="3" cellspacing="0" >
   <tr><td  align="center" width="85%">
    <%-- iframe for main chat transcript --%>
  
   <table height="100%" width="100%" cellpadding="3" cellspacing="0" >
    <tr valign="top">
    <td> <img src="getimage?image=logo&workgroup=<%= StringUtils.URLEncode(workgroup, "utf-8") %>"/></td>
     <td align="right" colspan="3">
     <a href="#" onClick="confirmExit();return false;" title="结束咨询">
     <img src="getimage?image=end&workgroup=<%= StringUtils.URLEncode(workgroup, "utf-8") %>" border="0">
     </a>
     </td>
    </tr>
	
 <tr>
     <td style="width:100%;height: 100%;" colspan="4">
     <iframe class="box" name="yak" src="yakframe.html" frameborder="0" marginheight="0" marginwidth="0"
             scrolling="auto" height="100%" width="100%" >
     </iframe>
     </td>
    </tr>
    <%
        SoundSettings soundSettings = null;
        try {
            soundSettings = chatSession.getWorkgroup().getSoundSettings();
        }
        catch (XMPPException e) {
        }
        if(soundSettings != null && soundSettings.getIncomingSoundBytes() != null){
    %>
    <tr>
    <td width="100%" colspan="4">
     <input type="checkbox" name="soundsEnabled" id="soundsEnabled" CHECKED/>播放声音
    </td>
    </tr>    
	<%  } %>
    <tr>
    <td style="width:60%;height: 30px; position:relative;" colspan="4" >
	<a class="f_face" href="javascript:;" title="表情"></a>
	
<div class="face_list" style="height:70px; left:10px; bottom:40px;">
<table class=" face_ico" cellpadding="0" style="height:70px;" cellspacing="1" border="0">
<tr>		
<td><a href="javascript:;"><img alt=">:o " src="images/emoticons/angry.gif" /></a></td>
<td><a href="javascript:;"><img alt=":-[ " src="images/emoticons/blush.gif" /></a></td>
<td><a href="javascript:;"><img alt="?:| " src="images/emoticons/confused.gif" /></a></td>
<td><a href="javascript:;"><img alt="B-) " src="images/emoticons/cool.gif" /></a></td>
<td><a href="javascript:;"><img alt=":'( " src="images/emoticons/cry.gif" /></a></td>
<td><a href="javascript:;"><img alt="]:) " src="images/emoticons/devil.gif" /></a></td>
</tr><tr>
<td><a href="javascript:;"><img alt=":-D " src="images/emoticons/grin.gif" /></a></td>
<td><a href="javascript:;"><img alt=":-) " src="images/emoticons/happy.gif" /></a></td>
<td><a href="javascript:;"><img alt=":^0 " src="images/emoticons/laugh.gif" /></a></td>
<td><a href="javascript:;"><img alt=":x " src="images/emoticons/love.gif" /></a></td>
<td><a href="javascript:;"><img alt=";\ " src="images/emoticons/mischief.gif" /></a></td>
<td><a href="javascript:;"><img alt=":-( " src="images/emoticons/sad.gif" /></a></td>
</tr><tr>
<td><a href="javascript:;"><img alt=":-) " src="images/emoticons/happy.gif" /></a></td>
<td><a href="javascript:;"><img alt=":| " src="images/emoticons/plain.gif" /></a></td>
<td><a href="javascript:;"><img alt=":0 " src="images/emoticons/shocked.gif" /></a></td>
<td><a href="javascript:;"><img alt=":-p " src="images/emoticons/silly.gif" /></a></td>
<td><a href="javascript:;"><img alt=";-) " src="images/emoticons/wink.gif" /></a></td>
<td><a href="javascript:;"><!-- <img alt="(!) " src="images/emoticons/wink.gif" /> --></a></td>
</tr>
</table>
</div>
	
	<!-- <a class="f_img" href="#" title="屏幕截图"></a> -->
	<span id="plugin_snapshot"></span>
   	<a class="f_img" href="#" onclick='insert_snapshot("loveto.cn")' title="屏幕截图"></a>
    <!-- <applet code="com.infoview.screenshot.ScreenShotApplet.class" archive="ScreenShot_signed.jar" codebase="." width="20" height="20" alt="截屏" align="middle" MAYSCRIPT>
    </applet>
     StringUtils.URLEncode(workgroup, "utf-8") StringUtils.escapeHTMLTags(chatID) -->
	<form name="upform" target="upload-frame" action="uploadServlet?workgroup=<%= StringUtils.escapeHTMLTags(workgroup) %>&chatID=<%= StringUtils.escapeHTMLTags(chatID) %>&userNickname=<%= StringUtils.escapeHTMLTags(userNickname) %>" method="post" enctype="multipart/form-data">
		<input type ="file" name="file1" id="file1" value="选择你要发送的文件"/>
		<input type="submit" name="Submit" value="上传文件给客服">
		<iframe name="upload-frame" id="upload-frame" style='display:none'></iframe>
	</form>
	</td>
    </tr>
	<tr><form name="f">
    <td width="100%" colspan="3">
      <textarea class="box inputbox"  cols="40" rows="4" name="chatbox" wrap="virtual"  style="width:100%;height:50px;overflow:hidden;"></textarea>
    </td></form>
    <td align="right" width="1%" nowrap valign="top">
     <img src="getimage?image=sendmessage&workgroup=<%= StringUtils.URLEncode(workgroup, "utf-8") %>"
         alt="Send Message"
         title="Send Message"
         onclick="javascript:submitMessage();"/>
    </td>

    </tr>
     <tr valign="bottom">
        <td colspan="4">
         <table width="100%" cellpadding="0" cellspacing="0">
            <tr valign="bottom"><td height="30"> <div id="typingAgent"></div></td>
             <td>
             <% if (request.isSecure()) { %>
				<div id="isSecure">
					<img src="images/secure_button.gif" border="0"/>
				</div>
             <%}%>
             </td> 
			</tr> 
		</table> 
   </td></tr>
   </table>
</td>
<td width="15%" align="center" valign="top"><!-- <%= StringUtils.URLEncode(city, "utf-8") %> -->
     <!--  <img src="getAd?city=<%= city %>" alt="" title="" onClick="javascript:;"/>-->
   <img src="<%= ad_pic %>" alt="" title="" onClick="javascript:;"/>
</td>
</tr>
</table>



 <div style="position:absolute;bottom:0px;right:5px;"><img src="getimage?image=poweredby&workgroup=<%= StringUtils.URLEncode(workgroup, "utf-8") %>"/></div>


    <script>
    var timeOut;

    function checkForNewMessages() {
       room.getAllMessages(insertMessages, '<%= chatID %>');
       lastChecked = new Date().getTime();
    }

    function checkIfAgentTyping() {
        room.isTyping(isTyping, '<%= chatID %>');
   }

   function isTyping(agentIsTyping){
     if(agentIsTyping){
        document.getElementById('typingAgent').innerHTML = '<img src="getimage?image=agenttyping&workgroup=<%= StringUtils.URLEncode(workgroup, "utf-8") %>" />'
     }
     else {
        document.getElementById('typingAgent').innerHTML = ''
     }
     setTimeout("checkIfAgentTyping()", 2000);
   }

   function insertMessages(messages){
   		
      if(messages == null){
        clearTimeout(timeOut);

        chatHasEnded();

        room.getEndMessage(showEndMessage, '<%= StringUtils.escapeHTMLTags(chatID)%>', '<%=StringUtils.escapeHTMLTags(workgroup)%>');
        return;
      }

      for(i=0; i<messages.length;i++){
         if(messages[i].cobrowsing){
           if(cobrowseWin && !cobrowseWin.closed){
             cobrowseWin.location.href= messages[i].urlToPush;
             cobrowseWin.focus();
           }
           else if(messages[i].body != null) {
              var urlToPush = messages[i].urlToPush;
              addText('', "<a href=javascript:parent.showCobrowser('"+urlToPush+"')>You have received a Cobrowsing invitation. Click to initiate a Cobrowser session.</a>");
           }
         }
         else {
         	alert("receiver:"+messages[i].body);
         	messages[i].body = messages[i].body.replace(/&gt;/gi,'>');
         	alert("receiver:"+messages[i].body);
          addChatText(window.frames['yak'], messages[i].from, messages[i].body);
         }
      }

      if(messages.length > 0 && !messages[0].cobrowsing){
        scrollYakToEnd(window.frames['yak']);
        document.getElementById('typingAgent').innerHTML = ''
        room.clearAgentTyping(null, '<%= StringUtils.escapeHTMLTags(chatID) %>');

        var hasSounds = document.getElementById("soundsEnabled");

        if (hasSounds != null && document.getElementById("soundsEnabled").checked) {
          // play incoming sound, if enabled
          document.getElementById("sounds").innerHTML=
              "<embed src='<%= request.getContextPath()%>/sounds?workgroup=<%=StringUtils.URLEncode(workgroup,"utf-8")%>&action=incoming' style=display:none; hidden=true autostart=true loop=false>";
        }

        // blink the window -- IE only
        if (document.all) {
            focus();
            document.f.chatbox.focus();
        }
        else {
           window.parent.focus();
        }
      }

      timeOut = setTimeout("checkForNewMessages()", 2000);
   }

      function showEndMessage(message){

        var ok = confirm(message);
        if(ok){
          isRedirecting = true;
          showTranscriptWindow(null);
        }
        else {
          window.location.href = "exit-window.jsp";
        }
      }
    </script>
   </body>
  </html>


